package com.qf.controller;

import com.qf.pojo.DtsAccountTrace;
import com.qf.pojo.DtsAddress;
import com.qf.pojo.DtsCollect;
import com.qf.pojo.DtsFootprint;
import com.qf.service.DtsAddressService;
import com.qf.service.DtsUserService;
import com.qf.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/admin")
public class AdminAddressController {
    @Autowired
    private DtsAddressService dtsAddressService;
    @Autowired
    private DtsUserService dtsUserService;

    //显示地址列表--分页
    @GetMapping("/address/list")
    public Object list(int page,int limit,String sort,String order){

        //获得佣金表集合  指定范围，页数以及每一页多少条
        List<DtsAddress> dtsAddress = dtsAddressService.find(page, limit, sort, order);
        //total总数
        Integer count = dtsAddressService.count();
        Map<String,Object> result =new HashMap<>();

        result.put("total",count);
        result.put("items",dtsAddress);
        return ResponseUtil.ok(result);

    }

    //会员收藏
    @GetMapping("/collect/list")
    public Object listcollection(int page,int limit,String sort,String order){

        //获得佣金表集合  指定范围，页数以及每一页多少条
        List<DtsCollect> dtsCollect = dtsUserService.findCollection(page, limit, sort, order);
        //total总数
        Integer count = dtsUserService.collectionCount();
        Map<String,Object> result =new HashMap<>();

        result.put("total",count);
        result.put("items",dtsCollect);
        return ResponseUtil.ok(result);
    }
    //会员足迹
    @GetMapping("/footprint/list")
    public Object listfootprint(int page,int limit,String sort,String order){

        //获得佣金表集合  指定范围，页数以及每一页多少条
        List<DtsFootprint> dtsFootprint = dtsUserService.findFootprint(page, limit, sort, order);
        //total总数
        Integer count = dtsUserService.footprintCount();
        Map<String,Object> result =new HashMap<>();

        result.put("total",count);
        result.put("items",dtsFootprint);
        return ResponseUtil.ok(result);
    }
}
